package com.util;

import java.security.MessageDigest;

public class MD5Util {
	public String transMD5(String text){
		StringBuffer buf = new StringBuffer("");
		try {
			MessageDigest md = MessageDigest.getInstance("MD5");  
	        md.update(text.getBytes());
	        byte b[] = md.digest();
	        int i;
	        for (int offset = 0; offset < b.length; offset++) {
	          i = b[offset];
	          if (i < 0)
	            i += 256;
	          if (i < 16)
	            buf.append("0");
	          buf.append(Integer.toHexString(i));
	        }
	        ;
		} catch (Exception e) {
			e.printStackTrace();
		}	
		return buf.toString();
	}
}
